package cn.itcast.user.web;

import cn.itcast.user.pojo.PatternProperties;
import cn.itcast.user.pojo.User;
import cn.itcast.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

//    @Value("${pattern.dateformate}")
//    private String dateformate;

    /**
     * 路径： /user/110
     *
     * @param id 用户id
     * @return 用户
     */
    @GetMapping("/{id}")
    public User queryById(@PathVariable("id") Long id,@RequestHeader("name")String a) {
        System.out.println(a);
        return userService.queryById(id);
    }

//    @Value("${pattern.dateformat}")
//    private String dateformat;

//    @Autowired
//    private PatternProperties patternProperties;

//    @GetMapping("now")
//    public String now(){
//        System.out.println(str);
//        return LocalDateTime.now().format(DateTimeFormatter.ofPattern(patternProperties.getDateformate()));
//        return LocalDateTime.now().format(DateTimeFormatter.ofPattern(dateformate));

}
